package com.zxn.japp;

import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentTransaction;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.alibaba.android.arouter.launcher.ARouter;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

@Route(path = IARouterConfig.HOME_TAB_ACTIVITY_URL)
public class TabActivity extends AppCompatActivity {

    @BindView(R.id.tv_1)
    TextView tv1;
    @BindView(R.id.tv_2)
    TextView tv2;
    @BindView(R.id.tv_3)
    TextView tv3;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_tab);
        ButterKnife.bind(this);

        ARouter.getInstance().inject(this);
    }

    @OnClick({R.id.tv_1, R.id.tv_2, R.id.tv_3})
    public void onViewClicked(View view) {
        String url = "";
        switch (view.getId()) {
            case R.id.tv_1:
                url = IARouterConfig.HOME_FIRST_FRAGMENT_URL;
                break;
            case R.id.tv_2:
                url = IARouterConfig.HOME_SECOND_FRAGMENT_URL;
                break;
            case R.id.tv_3:
                url = IARouterConfig.HOME_THIRD_FRAGMENT_URL;
                break;
        }
        Fragment fragment =
                (Fragment) ARouter.getInstance().build(url).navigation();
        FragmentTransaction fragmentTransaction =
                getSupportFragmentManager().beginTransaction();
        fragmentTransaction.replace(R.id.fl_container, fragment);
        fragmentTransaction.commit();
    }
}